package com.ruoyi.api.kehu;

import com.ruoyi.system.utils.TokenUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.JiajiaCharityActivitiesEnroll;
import com.ruoyi.system.service.IJiajiaCharityActivitiesEnrollService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公益活动报名Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/api/kehu/jiajiaCharityActivitiesEnroll")
public class ApiJiajiaCharityActivitiesEnrollController extends BaseController {
    @Autowired
    private IJiajiaCharityActivitiesEnrollService jiajiaCharityActivitiesEnrollService;

    /**
     * 查询公益活动报名列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll)
    {
        startPage();
        jiajiaCharityActivitiesEnroll.setUserId(TokenUtil.getUid());
        List<JiajiaCharityActivitiesEnroll> list = jiajiaCharityActivitiesEnrollService.selectJiajiaCharityActivitiesEnrollList(jiajiaCharityActivitiesEnroll);
        return getDataTable(list);
    }

    /**
     * 新增保存公益活动报名
     */
    @Log(title = "公益活动报名", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll)
    {
        return toAjax(jiajiaCharityActivitiesEnrollService.insertJiajiaCharityActivitiesEnroll(jiajiaCharityActivitiesEnroll));
    }

    /**
     * 公益活动报名完成提交
     */
    @Log(title = "公益活动报名", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll) {
        return toAjax(jiajiaCharityActivitiesEnrollService.updateJiajiaCharityActivitiesEnroll(jiajiaCharityActivitiesEnroll));
    }
}
